package com.ruoyi.teaching.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import freemarker.template.TemplateException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.teaching.domain.StageInvestigateDetail;
import com.ruoyi.teaching.service.IStageInvestigateDetailService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 阶段问卷细节Controller
 *
 * @author sunshine
 * @date 2024-02-15
 */
@RestController
@RequestMapping("/stage_investigate_detail")
public class StageInvestigateDetailController extends BaseController
{
    @Autowired
    private IStageInvestigateDetailService stageInvestigateDetailService;

    /**
     * 查询阶段问卷细节列表
     */
    @RequiresPermissions("teaching:stage_investigate_detail:list")
    @GetMapping("/list")
    public TableDataInfo list(StageInvestigateDetail stageInvestigateDetail)
    {
        startPage();
        List<StageInvestigateDetail> list = stageInvestigateDetailService.selectStageInvestigateDetailList(stageInvestigateDetail);
        return getDataTable(list);
    }
    /**
     * 查询阶段问卷细节列表
     */
    @RequiresPermissions("teaching:stage_investigate_detail:list")
    @GetMapping("/query")
    public TableDataInfo query()
    {
        List<StageInvestigateDetail> list = stageInvestigateDetailService.selectStageInvestigateDetailListByFeed();
        return getDataTable(list);
    }

    /**
     * 导出阶段问卷细节列表
     */
//    @RequiresPermissions("teaching:stage_investigate_detail:export")
//    @Log(title = "阶段问卷细节", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, StageInvestigateDetail stageInvestigateDetail)
//    {
//        List<StageInvestigateDetail> list = stageInvestigateDetailService.selectStageInvestigateDetailList(stageInvestigateDetail);
//        ExcelUtil<StageInvestigateDetail> util = new ExcelUtil<StageInvestigateDetail>(StageInvestigateDetail.class);
//        util.exportExcel(response, list, "阶段问卷细节数据");
//    }
    @RequiresPermissions("teaching:stage_investigate_detail:export")
    @Log(title = "阶段问卷细节", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export1(HttpServletResponse response, StageInvestigateDetail stageInvestigateDetail) throws TemplateException, IOException {
         stageInvestigateDetailService.export(response, stageInvestigateDetail);
    }
    /**
     * 获取阶段问卷细节详细信息
     */
    @RequiresPermissions("teaching:stage_investigate_detail:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stageInvestigateDetailService.selectStageInvestigateDetailById(id));
    }

    /**
     * 新增阶段问卷细节
     */
    @RequiresPermissions("teaching:stage_investigate_detail:add")
    @Log(title = "阶段问卷细节", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StageInvestigateDetail stageInvestigateDetail)
    {
        return toAjax(stageInvestigateDetailService.insertStageInvestigateDetail(stageInvestigateDetail));
    }

    /**
     * 修改阶段问卷细节
     */
    @RequiresPermissions("teaching:stage_investigate_detail:edit")
    @Log(title = "阶段问卷细节", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StageInvestigateDetail stageInvestigateDetail)
    {
        return toAjax(stageInvestigateDetailService.updateStageInvestigateDetail(stageInvestigateDetail));
    }

    /**
     * 删除阶段问卷细节
     */
    @RequiresPermissions("teaching:stage_investigate_detail:remove")
    @Log(title = "阶段问卷细节", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stageInvestigateDetailService.deleteStageInvestigateDetailByIds(ids));
    }
}
